<template>
  <NCard :bordered="false" size="small" class="card-wrapper">
    <NCollapse>
      <NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
        <NGrid responsive="screen" item-responsive>
          <NFormItemGi span="24 s:12 m:8" label="角色名称" path="searchKey" class="pr-24px">
            <NInput v-model:value="model.searchKey" placeholder="请输入角色名称关键词" clearable/>
          </NFormItemGi>

          <NFormItemGi span="24 m:16" class="pr-24px">
            <NSpace class="w-full" justify="end">
              <NButton @click="reset">
                <template #icon><icon-ic-round-refresh class="text-icon" /></template>
                重置
              </NButton>
              <NButton type="primary" ghost @click="search">
                <template #icon><icon-ic-round-search class="text-icon" /></template>
                查询
              </NButton>
            </NSpace>
          </NFormItemGi>
        </NGrid>
      </NForm>
    </NCollapse>
  </NCard>
</template>

<script setup lang="ts">
defineOptions({
  name: 'RoleSearch'
});

import { useNaiveForm } from '@/hooks/common/form';

interface Emits {
  (e: 'reset'): void;
  (e: 'search'): void;
}

const emit = defineEmits<Emits>();
const { formRef, validate, restoreValidation } = useNaiveForm();
// 查询表单
const model = defineModel<Api.SystemManage.SearchRoleParam>('model', { required: true });
// 重置
async function reset() {
  await restoreValidation();
  emit('reset');
}
// 查询
async function search() {
  await validate();
  emit('search');
}
</script>

<style scoped>

</style>
